class Solution(object):
    def searchRange(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        #find lower bound
        begin = 0
        end = len(nums)-1
        found = False
        while begin<=end:
            mid = (begin+end)//2
            val = nums[mid]
            if val>target:
                end=mid-1
            elif val<target:
                begin=mid+1
            else:
                found=True
                break
        if not found: return [-1, -1]

        begin = 0
        end = len(nums)-1
        while begin<end:
            mid = (begin+end)//2
            val = nums[mid]
            if val>target-1:
                end = mid-1
            elif val<target-1:
                begin = mid+1
            else:
                begin = mid+1
        lowBound = end
        begin = 0
        end = len(nums)-1
        while begin<end:
            mid = (begin+end)//2+1
            val = nums[mid]
            if val>target+1:
                end = mid-1
            elif val<target+1:
                begin = mid+1
            else:
                end = mid-1
        highBound = begin
        if 0<=lowBound<len(nums) and nums[lowBound]==target:
            pass
        else:
            lowBound+=1
        if 0<=highBound<len(nums) and nums[highBound]==target:
            pass
        else:
            highBound-=1
        return [lowBound, highBound]

print(Solution().searchRange([0,0], 0))